package com.tcg.prototype;

import android.app.Activity;
import android.app.ActivityGroup;
import android.app.ListActivity;
import android.app.LocalActivityManager;
import android.content.Intent;
import android.os.Bundle;
import android.util.*;
import android.view.View;
import android.view.Window;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

public class TCGInterfaceProtoActivity extends ActivityGroup {
    /** Called when the activity is first created. */
	
	FrameLayout contentArea;
	View activeView;
	View handView;
	View sideBoardView;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        contentArea = (FrameLayout) findViewById(R.id.content_area);

        handView = createActivity("handActivity", CardsAltActivity.class);
        sideBoardView = createActivity("sideBoardActivity", CardsAltActivity.class);
        
        setActiveView(handView);
    }
    
    private void setActiveView(View view) {
    	if (view != activeView)
    	{
    		if (activeView != null)
    			activeView.setVisibility(View.GONE);
    		
    		activeView = view;
    		activeView.setVisibility(View.VISIBLE);
    	}
	}

	public void btnCardsClick(View v)
    {
		setActiveView(handView);
    }

    public void btnSideBoardClick(View v)
    {
    	setActiveView(sideBoardView);
    }
    
    public void btnOptionsClick(View v)
    {
    	
    }
    public void btnGoalsClick(View v)
    {
    	
    }
    
	private View createActivity(String id, Class<CardsAltActivity> activityClass) {
		Intent intent = new Intent(this, activityClass);
        LocalActivityManager lam = getLocalActivityManager();
        Window win = lam.startActivity(id, intent);
        View result = win.getDecorView();
        result.setVisibility(View.GONE);

        contentArea.addView(result);
        
        return result;
	}

}